package com.ckx.service.impl;

import com.ckx.constants.SystemConstants;
import com.ckx.utils.SecurityUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("perm")
public class PermissionService {

    public boolean hasPermission(String permission) {
        if (SystemConstants.IS_ADMIN.equals(SecurityUtils.getUserId())) {
            //超级管理员什么都可以
            return true;
        }
        List<String> perms = SecurityUtils.getLoginUser().getPerms();
        return null != perms && perms.contains(permission);
    }

}
